import { Component, OnInit, Injector } from '@angular/core';
import { NgZorroPageBaseComponent } from '../../../core/ng-zorro-page-base-component/ng-zorro-page-base-component.component';
import { CityListComponent } from '../../school/cityList';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { NzMessageService, NzModalService } from 'ng-zorro-antd';
import {
  PagedResultDto, ClassInfoOutput, PagerSearchInput, HttpService, BaseComponentConfig,
  CustomNavigation, KeyValueOutput, SearchValue
} from '../../..';

@Component({
  selector: 'app-schooleditadd',
  templateUrl: './schooleditadd.component.html',
  styleUrls: ['./schooleditadd.component.scss']
})
export class SchooleditaddComponent implements OnInit {

  selectedProvince;
  selectedCity;
  schoolName = "";
  cityData: any;
  provinceData: any;
  listEntitiesdata: any;
  editid;
  resute;
  constructor(injecter: Injector,
    private router: Router,
    private message: NzMessageService,
    private activatedRoute: ActivatedRoute,
    public http: HttpService) {
    const city = new CityListComponent;
    this.provinceData = city.provinceDatas;
    this.cityData = city.cityDatas;

  }

  ngOnInit() {

  }
  provinceChange() {

  }
  async serve(type: string) {

    const that = this;
    that.resute = [];
    const address = this.selectedProvince + "-" + this.selectedCity;
    const data = {
      "schoolName": this.schoolName, "address": address
    };

    if (!this.schoolName || !this.selectedProvince || !this.selectedCity) {
      that.message.info('请填写完整');
      return false;
    } else {

      await that.http.post<any>("School/CreatSchool", data);
      this.message.create(type, `保存成功`);
      this.router.navigate(['app/management']);
    }
  }
}
